<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
//原始数据
let header = ['手机号', '姓名', '入职日期', '转正日期', '工号']
let results = [{"手机号":13951130870,"姓名":"高大山","入职日期":43535,"转正日期":43719,"工号":20089}]
const userRelations = {
  '入职日期': 'timeOfEntry',
  '手机号': 'mobile',
  '姓名': 'username',
  '转正日期': 'correctionTime',
  '工号': 'workNumber'
}
//目标数据
// let data = [{"mobile":13951130870,"username":"高大山","timeOfEntry":43535,"correctionTime":43719,"workNumber":20089}]
//(1)对象修改属性名
//方式1,在原来的对象当中做处理
/*
results[0].mobile = results[0]['手机号']
delete results[0]['手机号']
console.log(results[0])
*/
//方式2,在新的对象当中做处理
/*
let item = {}
item.mobile = results[0]['手机号']
console.log(item)
*/
//(2)久数组变成新数组,map
let data = results.map(t=>{
  let item = {}
  for(var key in t){
    let newKey = userRelations[key]
    item[newKey] = t[key]
  }
  return item
})
console.log(data)
</script>
</html>
